package main;

/**
 * 1 AC
 * 3 chaoshi
 */

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int T = in.nextInt();
        for (int i = 0; i < T; i++) {
            int n = in.nextInt();
            int m = in.nextInt();
        }
    }


    public static void main2(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();

        int[] arr = new int[n];
        int[] dp = new int[n];
        int max = arr[0];
        int length = 1;
        for (int i = 0; i < n; i++) {
            arr[i] = in.nextInt();
        }
        dp[0] = arr[0];
        for (int i = 1; i < n; i++) {
            for (int j = 0; j <= i; j++) {
                dp[j] = dp[j] | arr[i];
                if (dp[j] == max) {
                    int tmp = i - j + 1;
                    length = Math.min(length, tmp);
                }
                if (dp[j] > max) {
                    max = dp[j];
                    length = i - j + 1;
                }
            }
        }
        System.out.println(length);
    }

    @SuppressWarnings("all")
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        String str = in.next();
        in.close();
        char[] chars = str.toCharArray();
        int count = 0;
        int left, right = 0;

        if (chars.length % 2 == 0) {
            left = chars.length / 2 - 1;
            right = chars.length / 2;
        } else {
            left = chars.length / 2 - 1;
            right = chars.length / 2 + 1;
        }
        while (left >= 0) {
            if (chars[left] != chars[right]) {
                count++;
            }
            left--;
            right++;
        }
        System.out.println(count);
    }
}
